#!/bin/bash
# 使用while 和 if 来进行选择双色球

clear

echo "双色球选号"

redFont="\e[31m"
blueFont="\e[34m"
end="\e[0m"

result=""

while true
do
    #1-33是红球
    red=$[RANDOM%33+1]
    #如果数字已经存在了,继续循环
    echo "$result" | grep -w $red
    [ $? -eq 0 ] && continue
    result+="$red "
    wordcount=$(echo $result | wc -w)
    #如果红色为达到,继续红色
    [ $wordcount -ne 6 ] && continue
    result="$redFont$result$end"
    blue=$[RANDOM%16+1]
    result+="$blueFont$blue$end"
    break
done

echo -e $result
